package com.company.day2;
import java.util.Scanner;
// 输入a，b，c，并求出一元二次方程的根个数及其值
public class SolveEquation {
    public static void main(String[] args){
        // int n = 1;
        // while(n == 1){
        Scanner input = new Scanner(System.in);
        System.out.print("Enter a,b,c: ");
        double a = input.nextDouble();
        double b = input.nextDouble();
        double c = input.nextDouble();
        double delta = Math.pow(b,2)-4*a*c;
        if(delta > 0){
            double r1 = (-b + Math.pow(delta,0.5))/(2*a);
            double r2 = (-b - Math.pow(delta,0.5))/(2*a);
            System.out.println(" The equation has two roots " + r1 +" and " + r2);
        }else if(delta == 0){
            double r = -b/(2*a);
            System.out.println(" The equation has one root " + r );
        }else if(delta < 0){
            System.out.println(" The equation has no real roots ");
        }
        //  if(n == 0)
        //     break;
        //  }

    }
}
